package com.mdlib.helper.ui.adapter;

import android.graphics.drawable.Drawable;
import android.view.View;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.ljlib.help.R;
import com.mdlib.helper.model.entity.OrderEntity;

import java.util.List;

/**
 * 作者：HQY on 16/11/26 15:44
 * 邮箱：hqy_xz@126.com
 */

public class RushVicinityAdapter extends BaseQuickAdapter<OrderEntity> {

    public RushVicinityAdapter(List<OrderEntity> data) {
        super(R.layout.item_rush_vicinity, data);
    }

    @Override
    protected void convert(BaseViewHolder baseViewHolder, OrderEntity orderEntity) {

        baseViewHolder.setText(R.id.tv_run_vicinity_name, orderEntity.getRemark());
        baseViewHolder.setText(R.id.tv_rush_order_service_money, "￥" + orderEntity.getServiceMoney());
        baseViewHolder.setText(R.id.tv_run_distance, orderEntity.getDistance() + "km");
        baseViewHolder.setText(R.id.tv_order_address_two, orderEntity.getGetAddr());
        if (orderEntity.getOrderStatus() == 1) {
            baseViewHolder.getView(R.id.tv_vicinity_order_submit).setVisibility(View.VISIBLE);
        }

        TextView orderTake = baseViewHolder.getView(R.id.tv_order_address_one);
        if (orderEntity.getBusType() == 1) {

            Drawable agencys = mContext.getResources().getDrawable(R.drawable.vicinity_order_class);
            agencys.setBounds(0, 0, agencys.getMinimumWidth(), agencys.getMinimumHeight());
            orderTake.setCompoundDrawables(agencys, null, null, null);
            orderTake.setText(orderEntity.getHandleType());
            baseViewHolder.setImageResource(R.id.iv_rush_vicinity_type, R.drawable.iv_details_agecy);
            baseViewHolder.setText(R.id.tv_rush_vicinity_type, mContext.getResources().getString(R.string.send_home_agency));
        } else if (orderEntity.getBusType() == 2) {
            baseViewHolder.setImageResource(R.id.iv_rush_vicinity_type, R.drawable.iv_details_minnetonka);
            baseViewHolder.setText(R.id.tv_rush_vicinity_type, mContext.getResources().getString(R.string.send_home_minnetonka));
//            Drawable minn = mContext.getResources().getDrawable(R.drawable.vicinity_order_shop);
//            minn.setBounds(0, 0, minn.getMinimumWidth(), minn.getMinimumHeight());
//            orderTake.setCompoundDrawables(minn, null, null, null);
//            orderTake.setText(orderEntity.getHandleType());
        } else if (orderEntity.getBusType() == 3) {

            Drawable takes = mContext.getResources().getDrawable(R.mipmap.vicinity_order_take);
            takes.setBounds(0, 0, takes.getMinimumWidth(), takes.getMinimumHeight());
            orderTake.setCompoundDrawables(takes, null, null, null);
            orderTake.setText(orderEntity.getPostAddr());
            baseViewHolder.setImageResource(R.id.iv_rush_vicinity_type, R.drawable.iv_details_take);
            baseViewHolder.setText(R.id.tv_rush_vicinity_type, mContext.getResources().getString(R.string.send_home_take));
        }
        baseViewHolder.addOnClickListener(R.id.tv_vicinity_order_submit);
    }
}
